<template>
    <div class="chat-window">


        <div class="chat-list" style="margin-right: 2%;border-right: 2px solid black;">
            <div class="chat-headline">接收窗口</div>
            <div class="chat-ul" :class="type?'chat-ul1':'chat-ul2'">
                <div v-for="(item, index) in receiveChat.list" :key="index" class="receive-li chat-li">
                    <div class="li-head">{{ item.createTime }}</div>
                    <div class="li-text">{{ item.data }}</div>
                    <div class="li-text" v-show="item.sendTypeNum == '3'">{{ item.sendTypeText }}</div>
                    <div class="li-text"  v-if="item.base64Wave"> <audio controls style=" height: 40px;" :src="'data:audio/wav;base64,'+ item.base64Wave"></audio></div>
                </div>
            </div>
            <el-pagination @size-change="handleSizeChangeReceive" @current-change="handleCurrentChangeReceive" class="chat-pagination" small :pager-count="5"
                :current-page.sync="receiveChat.pageNum" :page-size="receiveChat.pageSize" layout="total,prev, pager, next, jumper" :total="receiveChat.total">
                <!-- :current-page.sync="receiveData.pageNum" :page-size="receiveData.pageSize" layout="total,prev, pager, next, jumper" :total="1000"> -->

            </el-pagination> 
        </div>
        <div class="chat-list" style="border-left: 2px solid black;">
            <div class="chat-headline">发送窗口</div>

            <div class="chat-ul" :class="type ?'chat-ul1':'chat-ul2'">
                <div v-for="(item, index) in sendChat.list" :key="index" class="send-li chat-li">
                    <div class="li-head">
                        <div>{{ item.dstId }}</div>
                        {{ item.createTime }}
                    </div>
                    <div class="li-text">{{ item.data }}</div>
                    <div class="li-text" v-show="item.sendTypeNum == '3'">{{ item.sendTypeText }}</div>
                    <div class="li-text"  v-if="item.base64Wave"> <audio controls style=" height: 40px;" :src="'data:audio/wav;base64,'+ item.base64Wave"></audio></div>
                </div>
            </div>

            <!-- <div class="li-text"  > <audio controls style=" height: 40px;" src="                        2024/01/25/base64_20240125162307A003.wav"></audio></div> -->
            <el-pagination @size-change="handleSizeChangeSend" @current-change="handleCurrentChangeSend" class="chat-pagination" small :pager-count="5"
                :current-page.sync="sendChat.pageNum" :page-size="sendChat.pageSize" layout="total,prev, pager, next, jumper" :total="sendChat.total">
                <!-- :current-page.sync="sendData.pageNum" :page-size="sendData.pageSize" layout="total,prev, pager, next, jumper" :total="1000"> -->
            </el-pagination>

        </div>
    </div>
</template>
  
<script>
export default {
    props: {
        chatArr: {
            type: Array,
            default: function () {
                return [
                   
                ];
            },
        },
        type:{
            type: Boolean,
        },
        receiveChat:{
            type:Object
        },
        sendChat:{
            type:Object
        }
    },
    watch: {
        sendChat(value){
            this.sendData = value
            console.log(value)
        },
        receiveChat(value) {
            this.receiveData = value
        }
    },
    data() {
        return {
            arr: [],
            receiveData: {
                list:[],
                pageNum:1,
                pageSize:10,
                total:0,
            },
            sendData: {
                list:[],
                pageNum:1,
                pageSize:10,
                total:0,
            },
            currentPage: 0,
        }
    },
    aisleList: {
            receiveArr(newList) {
                // 使用深拷贝创建新的数组，以确保监听到数组元素的变化
                // this.$emit("setAisleList", JSON.parse(JSON.stringify(newList)));
            },
            deep: true
        },
    mounted() {
        this.arr = this.chatArr
    },
    computed: {

    },
    methods: {
      
        //接收
        handleSizeChangeReceive(val) {
            // console.log(`每页 ${val} 条`);
            this.$emit("setReceivePageNum", val);
        },
        handleCurrentChangeReceive(val) {
            // console.log(`当前页: ${val}`);
            this.$emit("setReceivePageNum", val);

        },
        //发送
        handleSizeChangeSend(val) {
            // console.log(`每页 ${val} 条`);
            this.$emit("setSendPageNum", val);
        },
        handleCurrentChangeSend(val) {
            // console.log(`当前页: ${val}`);
            this.$emit("setSendPageNum", val);
        },

       

    }


};
</script>
  
<style lang="scss" scoped>
.chat-window {
    width: 100%;
    height: calc(100vh - 250px);
    display: flex;
    background: linear-gradient(to right, #313B53, #272F43);

    .chat-list {
        background: #171D2C;
        height: 100%;
        width: 49%;
        // border: 1px solid #2C334C;

    }

    .chat-headline {
        background: linear-gradient(to right, #2C334C, #1D2435);
        height: 40px;
        width: 100%;
        text-align: center;
        line-height: 40px;
        color: #676F7B;
    }

    .chat-list {


        .chat-ul {
            // height: calc(100vh - 250px);
            
            overflow-x: hidden;

        }
        .chat-ul1{
            height: calc(100% - 70px);
        }

        .chat-ul2{
            height: calc(100% - 120px);
        }

        .chat-ul::-webkit-scrollbar-thumb {
            background-color: #9A9DAA;
            // width: 2px;
        }

        .chat-ul::-webkit-scrollbar-track {
            background-color: transparent;
        }


        .chat-li {
            margin-top: 10px;
            padding: 5px 20px;

            .li-head {
                display: flex;
                align-items: center;
                font-size: 12px;
                color: #999999;
                div{
                    font-size: 14px;
                    margin-right: 10px;
                    color: #39BCB8; 
                }
            }

            .li-text {
                margin-top: 5px;
                font-size: 16px;
                color: #EDEDED;
            }
        }



        .send-li {
            .li-text {
                color: #39BCB8;
            }
        }
    }

}


::-webkit-scrollbar {
    background: transparent;
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background-color: #efefef;
    border-radius: 5px;
}



// .chat-pagination .btn-prev{
//     background-color: red;
// }

.chat-paginatio{
    width: 100%;
}
::v-deep .chat-pagination button{
    background-color: rgba(0, 0, 0, 0.00);;
}
::v-deep .chat-pagination li{
    background-color: rgba(0, 0, 0, 0.00);;
}
::v-deep .chat-pagination .el-pagination__editor .el-input__inner{
    background-color: rgba(0, 0, 0, 0.00);
    border:solid 1px #2BA0C8;
}
</style>

  